home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / gfx / misc / lise20.lha / lise2.0 / mdl / src / skeletton.c < prev    next >
C/C++ Source or Header  |  1993-03-31  |  7KB  |  275 lines

  1. /**---------------------------------------------------------------------
  2. ***
  3. ***   file:      skeletton.c
  4. ***
  5. ***   project:   skeletton for c-programs using procedural intuition access
  6. ***              ADD YOUR OWN ROUTINES AS SHOWN IN THE ROUTINE main(argc,argv)
  7. ***              AT THE END OF THIS FILE
  8. ***
  9. ***         (c) 1990 Rainer Kowallik
  10. ***
  11. ***-------------------------------------------------------------------*/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <math.h>
  16. #include <exec/types.h>
  17. #include <libraries/dos.h>
  18. #include <libraries/dosextens.h>
  19. #include <intuition/intuition.h>
  20. #include <workbench/workbench.h>
  21. #include <workbench/startup.h>
  22. #include <workbench/icon.h>
  23.  
  24. #include <mdllib.h>
  25.  
  26.  
  27. char  fs1_string[80];         /* user variable !!!!!!!! */
  28. int   scale_1;
  29. int   toggle_1;
  30.  
  31.  
  32. /* ---------------------------------------------
  33.          User Callback functions
  34.    --------------------------------------------- */
  35.  
  36. void show_scale()
  37. {
  38. char s[80];
  39. sprintf(s,"scale is %d\n",scale_1);
  40. Help(s);
  41. }
  42.  
  43. void show_toggle()
  44. {
  45. char s[80];
  46. sprintf(s,"flag is %d\n",toggle_1);
  47. Help(s);
  48. }
  49.  
  50. void setscale()
  51. {
  52.    scale_1 = scale_1 * 2;
  53. }
  54.  
  55. void settoggle()
  56. {
  57.    toggle_1 = toggle_1 ^ 1;
  58. }
  59.  
  60. void new_pointer()
  61. {
  62.    set_new_pointer();
  63. }
  64.  
  65. void old_pointer()
  66. {
  67.    set_old_pointer();
  68. }
  69.  
  70. void password()
  71. {
  72. char s[80],s1[80];
  73. StringBox("enter password",s);
  74. sprintf(s1,"you entered %s\n",s);
  75. Help(s1);
  76. }
  77.  
  78. void showrequest()
  79. {
  80. int n;
  81.  
  82.    n = RequestYesNo("you have the coice");
  83.    if(n) Help("You selected YES\n");
  84.    else  Help("You selected NO\n");
  85. }
  86.  
  87. void showfsel()
  88. {
  89. char *s;
  90.  
  91.    s = (char *) malloc(200);
  92.    FileSelect("File Select",s);
  93.    strcat(s,"\n");
  94.    Help(s);
  95.    free(s);
  96. }
  97.  
  98.  
  99. void whoami()
  100. {
  101. char s[512];
  102. strcpy(s,"Rainer Kowallik\nEisackstr. 14\n1000 Berlin 62\n");
  103. strcat(s,"Tel (030) 855 866 5\n\nBorn in 1962\n");
  104. strcat(s,"height 172 cm, weight 62 kg\n");
  105. strcat(s,"nice looking, not yet married\n");
  106. strcat(s,"graduated physicist working at HMI Berlin.\n");
  107. strcat(s,"I like (in this order)\n");
  108. strcat(s,"women, classic music, computers\n");
  109. strcat(s,"playing violin and good physics");
  110. Help(s);
  111. }
  112.  
  113. void whatfor()
  114. {
  115. char s[512];
  116. strcpy(s,"This is only a demonstration\n");
  117. strcat(s,"of what you can do with the\n");
  118. strcat(s,"SKELETTON program for\n");
  119. strcat(s,"procedural intuition access\n");
  120. strcat(s,"Please read the documentation\n");
  121. strcat(s,"SKELETTON.DOC\n");
  122. Help(s);
  123. }
  124.  
  125. void congratu()
  126. {
  127. char s[80];
  128. strcpy(s,"congratulation\n");
  129. Help(s);
  130. }
  131.  
  132.  
  133. void fs1()
  134. {
  135. char s[80];
  136. sprintf(s,"you selected %s\n",fs1_string);
  137. Help(s);
  138. }
  139.  
  140. /* **********************************************************************
  141.  
  142. You first have to write your call back routines, which are called
  143. when a menu point is selected, or a push button is pressed.
  144. Then you can add your functions to the intuition list at the main() routine
  145. using:
  146.  
  147.         add_item(x-pos, y-pos,TYPE,"text",opt1 , opt2);
  148.  
  149. Some items need a callback routine, some need a global variable to write to.
  150. These you can now add with:
  151.  
  152.         fn_command[fn_number] = (void *)CallbackRoutine;
  153.         var_value[fn_number] = &GlobalVariable;
  154.  
  155. Now you have to increment the fn_number.
  156. Available values for TYPE are:
  157.  
  158. Identifier      needs                comment
  159.  
  160. NEW_MENU        nothing              main point of menue, displayed in menu bar
  161. MENU            Callback             adds menu point under actual main point
  162. PUSH            Callback             adds a push button
  163. TOGGLE          Global variable      adds a toggle button
  164. SCALEX          Global variable      adds a scaler in x-direction
  165.                 opt1 = lowest value
  166.                 opt2 = highest value
  167. SCALEY          Global variable      adds a scaler in y-direction
  168. SELECTION       Global variable + Callback
  169.                                      adds a selector box with predefined items
  170. FILE_SELECT     Global variable + Callback
  171.                                      adds a file selector box
  172. STRING          Global variable + Callback
  173.                                      adds a string box
  174. INTEGER         Global variable + Callback
  175.                                      adds an integer box
  176. FLOAT           Global variable + Callback
  177.                                      adds a floatingpoint box
  178.  
  179. ******************************************************************** */
  180.  
  181. main(argc,argv)
  182. unsigned int argc;
  183. char *argv[];
  184. {
  185.  
  186. /* -------------------------------------------------------------------------
  187.    IF YOU NEED ACCESS TO THE WORK BENCH MESSAGES, YOU MAY USE THIS FRAGMENT
  188.    FROM THE ORIGINAL MDL
  189.  
  190.    if(argc > 1) {
  191.       strcpy(mdlfile,argv[1]);
  192.    } else {
  193.       IconBase = (struct IconBase *) OpenLibrary("icon.library", 0L);
  194.       Arg = WBenchMsg->sm_ArgList; Arg++;
  195.       CurrentDir(Arg->wa_Lock);
  196.       strcpy(mdlfile,Arg->wa_Name);
  197.    }
  198.    ------------------------------------------------------------------------- */
  199.  
  200. /* --- window geometry and name */
  201.   my_new_window = init_window(350,150,"skeletton test",0,1);
  202.  
  203. /* ----- initializing menus and requesters */
  204.  
  205.    add_item(-1,-1,NEW_MENU,"project",0,0);
  206.       fn_number++;
  207.    add_item(-1,-1,MENU,"show scale",0,0);
  208.       fn_command[fn_number] = (void *)show_scale;
  209.       fn_number++;
  210.    add_item(-1,-1,MENU,"show toggle",0,0);
  211.       fn_command[fn_number] = (void *)show_toggle;
  212.       fn_number++;
  213.    add_item(-1,-1,MENU,"new pointer",0,0);
  214.       fn_command[fn_number] = (void *)new_pointer;
  215.       fn_number++;
  216.    add_item(-1,-1,MENU,"old pointer",0,0);
  217.       fn_command[fn_number] = (void *)old_pointer;
  218.       fn_number++;
  219.    add_item(-1,-1,MENU,"password",0,0);
  220.       fn_command[fn_number] = (void *)password;
  221.       fn_number++;
  222.    add_item(-1,-1,MENU,"Request Yes/No",0,0);
  223.       fn_command[fn_number] = (void *)showrequest;
  224.       fn_number++;
  225.    add_item(-1,-1,MENU,"File Select",0,0);
  226.       fn_command[fn_number] = (void *)showfsel;
  227.       fn_number++;
  228.    add_item(-1,-1,MENU,"set toggle",0,0);
  229.       fn_command[fn_number] = (void *)settoggle;
  230.       fn_number++;
  231.    add_item(-1,-1,MENU,"set scale",0,0);
  232.       fn_command[fn_number] = (void *)setscale;
  233.       fn_number++;
  234.  
  235.    add_item(-1,-1,NEW_MENU,"help",0,0);
  236.       fn_number++;
  237.    add_item(-1,-1,MENU,"whoami",0,0);
  238.       fn_command[fn_number] = (void *)whoami;
  239.       fn_number++;
  240.    add_item(-1,-1,MENU,"whatfor",0,0);
  241.       fn_command[fn_number] = (void *)whatfor;
  242.       fn_number++;
  243.  
  244.    add_item(200,15,TOGGLE,"toggle here",0,0);
  245.       var_value[fn_number] = &toggle_1;
  246.       fn_number++;
  247.  
  248.    add_item(200,40,SCALEX,"moveme",0,100);
  249.       var_value[fn_number] = &scale_1;
  250.       fn_number++;
  251.  
  252.    add_item(220,80,PUSH,"PUSH HERE",0,0);
  253.       fn_command[fn_number] = (void *)congratu;
  254.       fn_number++;
  255.  
  256.    add_item(10,15,FILE_SELECT,"example",0,0);
  257.       var_value[fn_number] = (int *)&fs1_string;
  258.       fn_command[fn_number] = (void *)fs1;
  259.       fn_number++;
  260.  
  261.   my_window = (struct Window *) OpenWindow( my_new_window );
  262.   SetMenuStrip( my_window, menu_bar );
  263.   if(my_window == NULL)
  264.   {
  265.     close_gfx(NULL);
  266.     exit(0);
  267.   }
  268.  
  269.   fin_flg = FALSE;
  270.   MainLoop(my_window);
  271.  
  272.   exit(0);
  273. }
  274.  
  275.